/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.uniminuto.park.dao;

import co.uniminuto.park.clases.Estacionamiento;
import co.uniminuto.park.clases.Roles;

import co.uniminuto.park.variables.VariablesGlobales;
import com.google.code.morphia.Datastore;
import com.google.code.morphia.Morphia;
import com.google.code.morphia.query.Query;
import java.util.List;
import org.bson.types.ObjectId;

/**
 *
 * @author Esteban Rozo
 */
public class consultarRolDao extends ConexionMongo {

    private Morphia morphia;
    private Datastore ds;
    private ObjectId iden;

    public ObjectId getIden() {
        return iden;
    }

    public void setIden(ObjectId iden) {
        this.iden = iden;
    }
    
    

    public Morphia getMorphia() {
        return morphia;
    }

    public void setMorphia(Morphia morphia) {
        this.morphia = morphia;
    }

    public Datastore getDs() {
        return ds;
    }

    public void setDs(Datastore ds) {
        this.ds = ds;
    }

    public consultarRolDao() {
        super();
    }

    public List<Roles> getRoles() {
        this.morphia = new Morphia();
        this.morphia.map(Roles.class);
        this.ds = this.morphia.createDatastore(super.conectar(), VariablesGlobales.nombreBD);

        Query<Roles> q = ds.createQuery(Roles.class);
        List<Roles> ListaRoles = q.asList();
        return ListaRoles;
    }
    
    //busca por el object id 
       public Roles getParqueaderosOne(String id) {
        this.morphia = new Morphia();
        this.morphia.map(Roles.class);
        this.ds = this.morphia.createDatastore(super.conectar(), VariablesGlobales.nombreBD);
        //ObjectId id= new ObjectId();
        
      
        Query<Roles> q = ds.createQuery(Roles.class).field("idRol").equal(id);
        List<Roles> rol = q.asList();
        Roles tem= new Roles();
        tem=rol.get(0);
        return tem;
    }

    public static void main(String args[]) {
 
    }
}
